/**
 * 
 */
package com.unsanctioned.radioagregator.http.utils;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.util.Log;

/**
 * @author wizard
 *
 */
public class HttpRequestSupport {
	public static final String DOGTAG = HttpRequestSupport.class.getSimpleName();
	public static boolean isConnectionAvailable(Context context) {
		boolean isApplicationOnline = false;
		ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
		NetworkInfo[] ni = cm.getAllNetworkInfo();
		if (ni != null) {
			for (NetworkInfo networkInfo : ni) {
				if (networkInfo.isConnected()) isApplicationOnline = true;
				Log.i(DOGTAG, networkInfo.getTypeName() + ": " + (networkInfo.isConnected() ? "CONNECTED": "DISCONNECTED"));
			}
		}
		return isApplicationOnline;
	}
	
}
